<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>取得某像素的颜色索引值</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.imagecolorat" class="refentry">
  <div class="refnamediv">
   <h1 class="refname">imagecolorat</h1>
   <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">imagecolorat</span> &mdash; <span class="dc-title">取得某像素的颜色索引值</span></p>

  </div>
  <div class="refsect1 unknown-seealsp" id="refsect1-function.imagecolorat-unknown-seealsp">
   <h3 class="title">说明</h3>
   <div class="methodsynopsis dc-description">
    <span class="methodname"><strong>imagecolorat</strong></span>
     ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>
    , <span class="methodparam"><span class="type">int</span> <code class="parameter">$x</code></span>
    , <span class="methodparam"><span class="type">int</span> <code class="parameter">$y</code></span>
    ) : <span class="type">int</span></div>

   <p class="para rdfs-comment">
    返回 <code class="parameter">image</code> 所指定的图形中指定位置像素的颜色索引值。
   </p>
   <p class="para">
    如果 PHP 编译时加上了 GD 库 2.0
    或更高的版本并且图像是真彩色图像，则本函数以整数返回该点的 RGB
    值。用移位加掩码来取得红，绿，蓝各自成分的值：
    <div class="example" id="example-3664">
     <p><strong>Example #1 取得各自的 RGB 值</strong></p>
     <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$im&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ImageCreateFromPng</span><span style="color: #007700">(</span><span style="color: #DD0000">"rockym.png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$rgb&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ImageColorAt</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">=&nbsp;(</span><span style="color: #0000BB">$rgb&nbsp;</span><span style="color: #007700">&gt;&gt;&nbsp;</span><span style="color: #0000BB">16</span><span style="color: #007700">)&nbsp;&amp;&nbsp;</span><span style="color: #0000BB">0xFF</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$g&nbsp;</span><span style="color: #007700">=&nbsp;(</span><span style="color: #0000BB">$rgb&nbsp;</span><span style="color: #007700">&gt;&gt;&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">)&nbsp;&amp;&nbsp;</span><span style="color: #0000BB">0xFF</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$rgb&nbsp;</span><span style="color: #007700">&amp;&nbsp;</span><span style="color: #0000BB">0xFF</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
     </div>

    </div>
   </p>
   <p class="para">
    参见 <span class="function"><a href="imagecolorset.html" class="function">imagecolorset()</a></span> 和
    <span class="function"><a href="imagecolorsforindex.html" class="function">imagecolorsforindex()</a></span>。
   </p>
  </div>

 </div></div></div></body></html>